package com.libo.client;

import com.libo.bean.Environment;
import com.libo.client.gather.Gather;
import com.libo.client.gather.impl.GatherImpl;
import com.libo.client.send.Send;
import com.libo.client.send.impl.SendImpl;

import java.io.IOException;
import java.net.Socket;
import java.util.List;

/**
 * 客户端应用启动入口
 */
public class Client {

    public static void main(String[] args) {
        //数据采集
        Gather gather = new GatherImpl();
        List<Environment> environments = gather.gather();

        //发送数据给服务端
        //创建Socket连接
        Socket socket = null;
        try {
            socket = new Socket("127.0.0.1", 9999);
            //发送数据
            Send send = new SendImpl();
            send.send(environments,socket);

        }catch (IOException e){
            throw new RuntimeException(e);
        }finally {
            if(socket != null){
                try{
                    socket.close();
                }catch (IOException e){
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
